﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Linq;
using eAssessment.SPLinqLern;
using eAssessment.lists;

namespace eAssessment.Classes.Lists
{
    class AssessmentActiveListManager
    {
        public List<AssessmentType> GetActiveAssessments(SPWeb listWeb) 
        {
            DataContext data = new DataContext(listWeb.Url);
            EntityList<AssessmentType> assessments = data.GetList<AssessmentType>(ListAccessManager.AssessmentActiveListName);

            var query = from ass in assessments
                        where (DateTime.Now.CompareTo(ass.StartTime) >= 0 && DateTime.Now.CompareTo(ass.EndTime) <= 0)
                        select ass;
            return query.ToList<AssessmentType>();
        }

        
    }
}
